<template>
  <a-spin :spinning="spinning" tip="加载中...">
    <a-card :bordered="false">
      <h3>敏感词管理</h3>
      <a-form-model ref="rulesForm" :model="form" :rules="rules" :labelCol="{ lg: { span: 6 }, sm: { span: 8 } }" :wrapperCol="{ lg: { span: 14 }, sm: { span: 16 } }">
        <a-form-model-item label="敏感词" prop="nickName">
          <a-textarea v-model.trim="form.nickName" placeholder="多个敏感词用英文逗号,隔开" :rows="5" allowClear />
          <div>用户昵称、简介、评论如果包含了上诉敏感词，则无法保存成功</div>
        </a-form-model-item>
       <!-- <a-form-model-item label="个人简介敏感词" prop="introduction">
          <a-textarea v-model.trim="form.introduction" placeholder="多个敏感词用英文逗号,隔开" :rows="4" allowClear />
          <div>用户简介如果包含了上诉敏感词，则无法保存成功</div>
        </a-form-model-item> -->
        <a-form-model-item :wrapperCol="{ span: 24 }" style="text-align: center">
          <!-- <a-button style="margin-right: 8px" @click="handleBack">取消</a-button> -->
          <a-button htmlType="submit" @click="handleSubmit" type="primary">保存</a-button>
        </a-form-model-item>
      </a-form-model>
    </a-card>
  </a-spin>
</template>
<script>
import { sensitiveEdit, sensitiveSelect } from '@/api/micromall/configManagement'
export default {
  components: {
  },
  data() {
    return {
      spinning: false,
      form: {
      },
      rules: {
        nickName: [{ required: true, message: '请输入', trigger: 'blur' }],
        introduction: [{ required: true, message: '请输入', trigger: 'blur' }]
      }
    }
  },
  watch: {
  },
  created() {
    this.getDetails()
  },
  computed: {},
  mounted() {},
  beforeDestroy() {},
  methods: {
    // 获取详情
    getDetails() {
      this.spinning = true
      sensitiveSelect({})
        .then(res => {
          this.spinning = false
          if (res.code === 200) {
            this.form = {
              ...res.data
            }
          } else {
           this.$message.error(res.msg || res.message)
          }
        })
        .catch(err => { this.spinning = false})
    },

    // 保存
    handleSubmit() {
      this.$refs.rulesForm.validate(valid => {
        if (valid) {
          const data = {
            ...this.form
          }
          sensitiveEdit(data).then(res => {
          if (res.code === 200) {
            this.$message.success('保存成功！')
            this.getDetails()
          } else {
            this.$message.error(res.msg || res.message)
          }
        })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },

    //返回
    handleBack() {
      this.$router.go(-1)
    },

    getUploadParams() {
      return {
        actionUrl: 'https://jic.jnby.com/activity/market-act/common/upload/multipart',
        headers: {
          authorization: 'authorization-text'
        },
        uploadHost: 'https://img.bzhz.jnbygroup.com/'
      }
    },
    // 图片change
    fileImageChange(list) {
      this.form.imgList = list
    }
  }
}
</script>
<style lang="less" scoped>
.hidden-title /deep/ .ant-form-item-label > label {
  visibility: hidden;
}
</style>
